/*
 Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
 Original sources are available at www.latestbit.com

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 RequestContext.hpp. Created on: 08.09.2009 12:09:05
 */

#ifndef REQUESTCONTEXT_HPP_
#define REQUESTCONTEXT_HPP_

#include "smartobjects/SmartObjectsDefs.hpp"
#include "ISmartBus.hpp"
#include "ISerializableObject.hpp"

namespace smartobjects {

class RequestContext : public ISerializableObject, public virtual RefObject {

public:
	SO_DLLPRFX static const unsigned int DEFAULT_COMMAND_OPERATION_TIMEOUT;

public:
	SO_DLLPRFX RequestContext();
	SO_DLLPRFX virtual ~RequestContext();

	SO_DLLPRFX virtual void serialize(IDataTypesCoder* poCoder, IDataEncrypter* poEncrypter, ByteBuffer* poToBuffer) const;
	SO_DLLPRFX virtual void deserialize(IDataTypesCoder* poCoder, IDataEncrypter* poEncrypter, ByteBuffer* poFromBuffer);
	SO_DLLPRFX virtual const std::string& getObjectType() const;

	SO_DLLPRFX virtual ISmartBus* getBus();
	SO_DLLPRFX virtual void setBus(ISmartBus*);

	SO_DLLPRFX virtual class ServerSkeleton* getSkeleton();
	SO_DLLPRFX virtual void setSkeleton(class ServerSkeleton*);

	SO_DLLPRFX virtual class ConnectionHandler* getConnectionHandler();
	SO_DLLPRFX virtual void setConnectionHandler(class ConnectionHandler*);

	SO_DLLPRFX virtual void setUserContextBuffer(const std::vector<unsigned char>&);
	SO_DLLPRFX virtual std::vector<unsigned char>& getUserContextBuffer();

	SO_DLLPRFX virtual unsigned int getMaxResponseTimeoutInSec();
	SO_DLLPRFX virtual void setMaxResponseTimeoutInSec(unsigned int);

protected:
	SO_DLLPRFX static const std::string RC_OBJECT_TYPE;

protected:
	unsigned int m_nResponseTimeout;
	std::string m_sLocale;
	std::string m_sTimezone;

	ISmartBus* m_poSmartBus;
	class ServerSkeleton* m_poSkeleton;
	class ConnectionHandler* m_poConnectionHandler;
	std::vector<unsigned char> m_aUserContextBuffer;
};

}

#endif /* REQUESTCONTEXT_HPP_ */
